﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Powerpoint
{
    public class Statistics
    {

        //# Notifications
        public int notifications { get; set; }
        public Dictionary<DateTime, float> notificationHistory = new Dictionary<DateTime, float>();
        public Dictionary<DateTime, float> totalNotificationHistory = new Dictionary<DateTime, float>();
        bool firstNotification = true;
        DateTime lastNotification = new DateTime();

        //Sum of motion
        public float motionSum { get; set; }

        //Sum of volume
        public float volumeSum { get; set; }

        //Motion History
        public Dictionary<DateTime,float> motionHistory = new Dictionary<DateTime,float>();

        //Volume History
        public Dictionary<DateTime, float> volumeHistory = new Dictionary<DateTime, float>();

        public Statistics()
        {
            notifications = 0;
            motionSum = 0;
            volumeSum = 0;
        }

        /// <summary>
        /// Add Notification
        /// </summary>
        public void addNotification()
        {
            notifications++;
            totalNotificationHistory.Add(System.DateTime.Now, notifications);

            if (firstNotification)
            {
                firstNotification = false;
                lastNotification = System.DateTime.Now;
                notificationHistory.Add(lastNotification, 1);
            }
            else
            {
                if ((System.DateTime.Now.Minute*60+System.DateTime.Now.Second) - (lastNotification.Minute*60 + lastNotification.Second) < 20)
                {
                    notificationHistory[lastNotification]+=1;
                }
                else                 
                {
                    lastNotification = System.DateTime.Now;
                    notificationHistory.Add(lastNotification, 1);
                }
            }
        }

        public void addVolume(float newVolume)
        {
            volumeSum += newVolume;
            volumeHistory.Add(System.DateTime.Now, newVolume);
        }

        /// <summary>
        /// Add new Motionvector
        /// </summary>
        /// <param name="newMotion">Current Motion</param>
        public void addMotion(float newMotion)
        {
            motionSum += newMotion;
            motionHistory.Add(System.DateTime.Now,newMotion);
        }


    }
}
